<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveRecord::ConnectionAdapters::DatabaseStatements</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveRecord::ConnectionAdapters::DatabaseStatements</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements_rb.html">
                vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001186">add_limit!</a>&nbsp;&nbsp;
      <a href="#M001187">add_limit_offset!</a>&nbsp;&nbsp;
      <a href="#M001188">add_lock!</a>&nbsp;&nbsp;
      <a href="#M001183">begin_db_transaction</a>&nbsp;&nbsp;
      <a href="#M001184">commit_db_transaction</a>&nbsp;&nbsp;
      <a href="#M001189">default_sequence_name</a>&nbsp;&nbsp;
      <a href="#M001181">delete</a>&nbsp;&nbsp;
      <a href="#M001196">delete_sql</a>&nbsp;&nbsp;
      <a href="#M001192">empty_insert_statement</a>&nbsp;&nbsp;
      <a href="#M001178">execute</a>&nbsp;&nbsp;
      <a href="#M001179">insert</a>&nbsp;&nbsp;
      <a href="#M001191">insert_fixture</a>&nbsp;&nbsp;
      <a href="#M001194">insert_sql</a>&nbsp;&nbsp;
      <a href="#M001190">reset_sequence!</a>&nbsp;&nbsp;
      <a href="#M001185">rollback_db_transaction</a>&nbsp;&nbsp;
      <a href="#M001193">select</a>&nbsp;&nbsp;
      <a href="#M001173">select_all</a>&nbsp;&nbsp;
      <a href="#M001174">select_one</a>&nbsp;&nbsp;
      <a href="#M001177">select_rows</a>&nbsp;&nbsp;
      <a href="#M001175">select_value</a>&nbsp;&nbsp;
      <a href="#M001176">select_values</a>&nbsp;&nbsp;
      <a href="#M001182">transaction</a>&nbsp;&nbsp;
      <a href="#M001180">update</a>&nbsp;&nbsp;
      <a href="#M001195">update_sql</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001186" class="method-detail">
        <a name="M001186"></a>

        <div class="method-heading">
          <a href="#M001186" class="method-signature">
          <span class="method-name">add_limit!</span><span class="method-args">(sql, options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Alias for add_limit_offset!.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001186-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001186-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 97</span>
97:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_limit!</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">options</span>)
98:         <span class="ruby-identifier">add_limit_offset!</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">options</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>
99:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001187" class="method-detail">
        <a name="M001187"></a>

        <div class="method-heading">
          <a href="#M001187" class="method-signature">
          <span class="method-name">add_limit_offset!</span><span class="method-args">(sql, options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Appends <tt>LIMIT</tt> and <tt>OFFSET</tt> options to an SQL statement.
This method <b>modifies</b> the <tt>sql</tt> parameter.
</p>
<h5>Examples</h5>
<pre>
 add_limit_offset!('SELECT * FROM suppliers', {:limit =&gt; 10, :offset =&gt; 50})
</pre>
<p>
generates
</p>
<pre>
 SELECT * FROM suppliers LIMIT 10 OFFSET 50
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001187-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001187-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 107</span>
107:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_limit_offset!</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">options</span>)
108:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">limit</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:limit</span>]
109:           <span class="ruby-identifier">sql</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; LIMIT #{limit}&quot;</span>
110:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">offset</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:offset</span>]
111:             <span class="ruby-identifier">sql</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; OFFSET #{offset}&quot;</span>
112:           <span class="ruby-keyword kw">end</span>
113:         <span class="ruby-keyword kw">end</span>
114:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001188" class="method-detail">
        <a name="M001188"></a>

        <div class="method-heading">
          <a href="#M001188" class="method-signature">
          <span class="method-name">add_lock!</span><span class="method-args">(sql, options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Appends a locking clause to an SQL statement. This method <b>modifies</b>
the <tt>sql</tt> parameter.
</p>
<pre>
  # SELECT * FROM suppliers FOR UPDATE
  add_lock! 'SELECT * FROM suppliers', :lock =&gt; true
  add_lock! 'SELECT * FROM suppliers', :lock =&gt; ' FOR UPDATE'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001188-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001188-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 121</span>
121:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_lock!</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">options</span>)
122:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">lock</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:lock</span>]
123:           <span class="ruby-keyword kw">when</span> <span class="ruby-keyword kw">true</span>;   <span class="ruby-identifier">sql</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">' FOR UPDATE'</span>
124:           <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>; <span class="ruby-identifier">sql</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; #{lock}&quot;</span>
125:         <span class="ruby-keyword kw">end</span>
126:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001183" class="method-detail">
        <a name="M001183"></a>

        <div class="method-heading">
          <a href="#M001183" class="method-signature">
          <span class="method-name">begin_db_transaction</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Begins the <a href="DatabaseStatements.html#M001182">transaction</a> (and
turns off auto-committing).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001183-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001183-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 87</span>
87:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">begin_db_transaction</span>()    <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001184" class="method-detail">
        <a name="M001184"></a>

        <div class="method-heading">
          <a href="#M001184" class="method-signature">
          <span class="method-name">commit_db_transaction</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Commits the <a href="DatabaseStatements.html#M001182">transaction</a> (and
turns on auto-committing).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001184-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001184-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 90</span>
90:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">commit_db_transaction</span>()   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001189" class="method-detail">
        <a name="M001189"></a>

        <div class="method-heading">
          <a href="#M001189" class="method-signature">
          <span class="method-name">default_sequence_name</span><span class="method-args">(table, column)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001189-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001189-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 128</span>
128:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default_sequence_name</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">column</span>)
129:         <span class="ruby-keyword kw">nil</span>
130:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001181" class="method-detail">
        <a name="M001181"></a>

        <div class="method-heading">
          <a href="#M001181" class="method-signature">
          <span class="method-name">delete</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes the <a href="DatabaseStatements.html#M001181">delete</a> statement
and returns the number of rows affected.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001181-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001181-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 53</span>
53:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
54:         <span class="ruby-identifier">delete_sql</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
55:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001192" class="method-detail">
        <a name="M001192"></a>

        <div class="method-heading">
          <a href="#M001192" class="method-signature">
          <span class="method-name">empty_insert_statement</span><span class="method-args">(table_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001192-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001192-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 143</span>
143:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty_insert_statement</span>(<span class="ruby-identifier">table_name</span>)
144:         <span class="ruby-node">&quot;INSERT INTO #{quote_table_name(table_name)} VALUES(DEFAULT)&quot;</span>
145:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001178" class="method-detail">
        <a name="M001178"></a>

        <div class="method-heading">
          <a href="#M001178" class="method-signature">
          <span class="method-name">execute</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes the SQL statement in the context of this connection.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001178-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001178-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 38</span>
38:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
39:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">&quot;execute is an abstract method&quot;</span>
40:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001179" class="method-detail">
        <a name="M001179"></a>

        <div class="method-heading">
          <a href="#M001179" class="method-signature">
          <span class="method-name">insert</span><span class="method-args">(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the last auto-generated ID from the affected table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001179-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001179-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 43</span>
43:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">insert</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">pk</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">id_value</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">sequence_name</span> = <span class="ruby-keyword kw">nil</span>)
44:         <span class="ruby-identifier">insert_sql</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">pk</span>, <span class="ruby-identifier">id_value</span>, <span class="ruby-identifier">sequence_name</span>)
45:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001191" class="method-detail">
        <a name="M001191"></a>

        <div class="method-heading">
          <a href="#M001191" class="method-signature">
          <span class="method-name">insert_fixture</span><span class="method-args">(fixture, table_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Inserts the given fixture into the table. Overridden in adapters that
require something beyond a simple <a
href="DatabaseStatements.html#M001179">insert</a> (eg. Oracle).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001191-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001191-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 139</span>
139:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">insert_fixture</span>(<span class="ruby-identifier">fixture</span>, <span class="ruby-identifier">table_name</span>)
140:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;INSERT INTO #{quote_table_name(table_name)} (#{fixture.key_list}) VALUES (#{fixture.value_list})&quot;</span>, <span class="ruby-value str">'Fixture Insert'</span>
141:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001190" class="method-detail">
        <a name="M001190"></a>

        <div class="method-heading">
          <a href="#M001190" class="method-signature">
          <span class="method-name">reset_sequence!</span><span class="method-args">(table, column, sequence = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Set the sequence to the max value of the table&#8216;s column.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001190-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001190-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 133</span>
133:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset_sequence!</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">column</span>, <span class="ruby-identifier">sequence</span> = <span class="ruby-keyword kw">nil</span>)
134:         <span class="ruby-comment cmt"># Do nothing by default.  Implement for PostgreSQL, Oracle, ...</span>
135:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001185" class="method-detail">
        <a name="M001185"></a>

        <div class="method-heading">
          <a href="#M001185" class="method-signature">
          <span class="method-name">rollback_db_transaction</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Rolls back the <a href="DatabaseStatements.html#M001182">transaction</a>
(and turns on auto-committing). Must be done if the <a
href="DatabaseStatements.html#M001182">transaction</a> block raises an
exception or returns false.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001185-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001185-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 94</span>
94:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rollback_db_transaction</span>() <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001173" class="method-detail">
        <a name="M001173"></a>

        <div class="method-heading">
          <a href="#M001173" class="method-signature">
          <span class="method-name">select_all</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an array of record hashes with the column names as keys and column
values as values.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001173-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001173-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 6</span>
6:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_all</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
7:         <span class="ruby-identifier">select</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
8:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001174" class="method-detail">
        <a name="M001174"></a>

        <div class="method-heading">
          <a href="#M001174" class="method-signature">
          <span class="method-name">select_one</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a record hash with the column names as keys and column values as
values.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001174-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001174-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 12</span>
12:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_one</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
13:         <span class="ruby-identifier">result</span> = <span class="ruby-identifier">select_all</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
14:         <span class="ruby-identifier">result</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>
15:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001177" class="method-detail">
        <a name="M001177"></a>

        <div class="method-heading">
          <a href="#M001177" class="method-signature">
          <span class="method-name">select_rows</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an array of arrays containing the field values. Order is the same
as that returned by columns.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001177-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001177-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 33</span>
33:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_rows</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
34:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">&quot;select_rows is an abstract method&quot;</span>
35:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001175" class="method-detail">
        <a name="M001175"></a>

        <div class="method-heading">
          <a href="#M001175" class="method-signature">
          <span class="method-name">select_value</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a single value from a record
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001175-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001175-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 18</span>
18:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_value</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
19:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span> = <span class="ruby-identifier">select_one</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
20:           <span class="ruby-identifier">result</span>.<span class="ruby-identifier">values</span>.<span class="ruby-identifier">first</span>
21:         <span class="ruby-keyword kw">end</span>
22:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001176" class="method-detail">
        <a name="M001176"></a>

        <div class="method-heading">
          <a href="#M001176" class="method-signature">
          <span class="method-name">select_values</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an array of the values of the first column in a <a
href="DatabaseStatements.html#M001193">select</a>:
</p>
<pre>
  select_values(&quot;SELECT id FROM companies LIMIT 3&quot;) =&gt; [1,2,3]
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001176-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001176-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 26</span>
26:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_values</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
27:         <span class="ruby-identifier">result</span> = <span class="ruby-identifier">select_rows</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
28:         <span class="ruby-identifier">result</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">0</span>] }
29:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001182" class="method-detail">
        <a name="M001182"></a>

        <div class="method-heading">
          <a href="#M001182" class="method-signature">
          <span class="method-name">transaction</span><span class="method-args">(start_db_transaction = true) {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Wrap a block in a <a
href="DatabaseStatements.html#M001182">transaction</a>. Returns result of
block.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001182-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001182-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 58</span>
58:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transaction</span>(<span class="ruby-identifier">start_db_transaction</span> = <span class="ruby-keyword kw">true</span>)
59:         <span class="ruby-identifier">transaction_open</span> = <span class="ruby-keyword kw">false</span>
60:         <span class="ruby-keyword kw">begin</span>
61:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
62:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">start_db_transaction</span>
63:               <span class="ruby-identifier">begin_db_transaction</span>
64:               <span class="ruby-identifier">transaction_open</span> = <span class="ruby-keyword kw">true</span>
65:             <span class="ruby-keyword kw">end</span>
66:             <span class="ruby-keyword kw">yield</span>
67:           <span class="ruby-keyword kw">end</span>
68:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">database_transaction_rollback</span>
69:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">transaction_open</span>
70:             <span class="ruby-identifier">transaction_open</span> = <span class="ruby-keyword kw">false</span>
71:             <span class="ruby-identifier">rollback_db_transaction</span>
72:           <span class="ruby-keyword kw">end</span>
73:           <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">database_transaction_rollback</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Rollback</span>
74:         <span class="ruby-keyword kw">end</span>
75:       <span class="ruby-keyword kw">ensure</span>
76:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">transaction_open</span>
77:           <span class="ruby-keyword kw">begin</span>
78:             <span class="ruby-identifier">commit_db_transaction</span>
79:           <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">database_transaction_rollback</span>
80:             <span class="ruby-identifier">rollback_db_transaction</span>
81:             <span class="ruby-identifier">raise</span>
82:           <span class="ruby-keyword kw">end</span>
83:         <span class="ruby-keyword kw">end</span>
84:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001180" class="method-detail">
        <a name="M001180"></a>

        <div class="method-heading">
          <a href="#M001180" class="method-signature">
          <span class="method-name">update</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes the <a href="DatabaseStatements.html#M001180">update</a> statement
and returns the number of rows affected.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001180-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001180-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 48</span>
48:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
49:         <span class="ruby-identifier">update_sql</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
50:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M001196" class="method-detail">
        <a name="M001196"></a>

        <div class="method-heading">
          <a href="#M001196" class="method-signature">
          <span class="method-name">delete_sql</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes the <a href="DatabaseStatements.html#M001181">delete</a> statement
and returns the number of rows affected.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001196-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001196-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 166</span>
166:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_sql</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
167:           <span class="ruby-identifier">update_sql</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
168:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001194" class="method-detail">
        <a name="M001194"></a>

        <div class="method-heading">
          <a href="#M001194" class="method-signature">
          <span class="method-name">insert_sql</span><span class="method-args">(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the last auto-generated ID from the affected table.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001194-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001194-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 155</span>
155:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">insert_sql</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">pk</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">id_value</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">sequence_name</span> = <span class="ruby-keyword kw">nil</span>)
156:           <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
157:           <span class="ruby-identifier">id_value</span>
158:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001193" class="method-detail">
        <a name="M001193"></a>

        <div class="method-heading">
          <a href="#M001193" class="method-signature">
          <span class="method-name">select</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns an array of record hashes with the column names as keys and column
values as values.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001193-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001193-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 150</span>
150:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
151:           <span class="ruby-identifier">raise</span> <span class="ruby-constant">NotImplementedError</span>, <span class="ruby-value str">&quot;select is an abstract method&quot;</span>
152:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001195" class="method-detail">
        <a name="M001195"></a>

        <div class="method-heading">
          <a href="#M001195" class="method-signature">
          <span class="method-name">update_sql</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Executes the <a href="DatabaseStatements.html#M001180">update</a> statement
and returns the number of rows affected.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001195-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001195-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb, line 161</span>
161:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_sql</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
162:           <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>)
163:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>